﻿#include "MainWidget.h"
#include "Define.h"
#include "MyThread.h"
//void MainWidget::qDebugInfo()
void Debug::run()
{
    while(1)
    {
        if(focus_gun_ != 0)
        {
        //    printf("chargingData->gunmsg[0].gun_conn_state = %d\n", chargingData->gunmsg[0].gun_conn_state);
            printf("chargingData->gunmsg[%d].gun_conn_state = %d\n",focus_gun_-1, chargingData->gunmsg[focus_gun_-1].gun_conn_state);
            printf("枪个数: %d\t当前的枪号: %d\t枪标识: %d\n", chargingData->gunnum , focus_gun_-1, focus_gun_);
            printf("%d号枪的错误代码: chargingData->gunmsg[%d].errcode[0] = %d\n", focus_gun_, focus_gun_-1, chargingData->gunmsg[focus_gun_-1].errcode[0]);
            printf("%d号枪的电表异常代码: %d\n", focus_gun_, chargingData->gunmsg[focus_gun_-1].meter_state);
            qDebug("%d号枪CAN通讯异常代码:%d\n", focus_gun_, chargingData->can_state[focus_gun_-1]);
            printf("%d号枪的充电状态: %d\t%d号枪的连接状态: %d\n", focus_gun_, chargingData->gunmsg[focus_gun_-1].charge_state,focus_gun_, chargingData->gunmsg[focus_gun_-1].gun_conn_state);
            printf("%d号枪的充电方式是: %d\t%d号枪的结束验证码是: %s\n", focus_gun_, chargingData->cmd3[focus_gun_-1].state, focus_gun_, chargingData->cmd3[focus_gun_-1].stopcode);
            printf("%d号枪的停止原因是: %d\n", focus_gun_, chargingData->gunmsg[focus_gun_-1].stopreason);
            printf("读卡器通信状态: %d\n", card->errcode);
            qDebug("刷卡线程是否启动:%d\n",mt.isRunning());
//            for(int i=0; i<GUN_AMOUNT; i++)
//            {
//                qDebug()<<"swipCardflag["<<Refreash_Thread[i].GUN_NO<<"] == "<<Refreash_Thread[i].swipCardflag;
//            }
        //    m_errcode = chargingData->gunmsg[m_num].errcode[0];
        //    m_meter_state = chargingData->gunmsg[m_num].meter_state;
        //    m_can_state = chargingData->can_state[m_num];

        //    printf("%d号枪的SOC的值是: %d\n", m_num+1, chargingData->gunmsg[m_num].u2.dc.MX[2]);
            printf("%d号枪的启动成功标志是: %d\n", focus_gun_, chargingData->cmd2[focus_gun_-1].result);
            qDebug() << tr("当前页面是: ") << stackLayout->currentIndex();
    //        printf("当前的刷卡的方式是: %d\n", ThreadFlag);
//            printf("电流的类型: %d\n", chargingData->devtype);
        //    printf("1号枪倒计时: %d, 2号枪的倒计时: %d\n", m_oneCountDownTime, m_twoCountDownTime);
    //        printf("m_stop1: %d, m_stop2: %d, m_stop3: %d\n", m_stop1, m_stop2, m_stop3);
    //        printf("m_connect1: %d, m_connect2: %d\n", m_connect1, m_connect2);
    //        qDebug() << tr("定时器1的状态: ") << timerOneGunSettleAccount->isActive() << tr("; 定时器2的状态: ") << timerTwoGunSettleAccount->isActive();
        //    qDebug() << tr("错误信息1定时器的状态: ") << timerErrorInfo->isActive();
        //    qDebug() << tr("错误信息2定时器的状态: ") << timerErrorInfoTwo->isActive();
        //    qDebug() << tr("DC1定时器的状态: ") << timerUpdateDCOne->isActive();
        //    qDebug() << tr("DC2定时器的状态: ") << timerUpdateDCTwo->isActive();
        //    qDebug() << tr("等待连接枪的倒计时: ") << timerUpdateGunConnect->isActive();
        //    qDebug() << tr("更新枪1的结算的倒计时: ") << timerUPdataStatues->isActive();
        //    qDebug() << tr("更新枪2的结算的倒计时: ") << timerUpdataSettleAccountTwo->isActive();
            printf("%d号桩故障码: %d\n", focus_gun_,chargingData->gunmsg[focus_gun_-1].m_stopReason);
        //    printf("2桩故障码: %d\n", chargingData->gunmsg[1].m_stopReason);
        //    printf("1号枪的CAN状态: %d\n", chargingData->can_state[0]);
        //    printf("2号枪的CAN状态: %d\n", chargingData->can_state[1]);
        //    qDebug() << tr("刷卡和二维码界面上的倒计时: ") << timerChargeType->isActive();
    //        qDebug() << tr("1号枪的充电方式: ") << updateChargeWay.isRunning();
    //        qDebug() << tr("2号枪的充电方式: ") << updateTwoGunChargeWay->isActive();
        //    qDebug() << tr("枪1未连接计时器: ") << timerUpdateOneGunNotConnect->isActive() << tr("; 倒计时值: ") << m_time26_1;
        //    qDebug() << tr("枪2未连接计时器: ") << timerUpdateTwoGunNotConnect->isActive() << tr("; 倒计时值: ") << m_time26_2;
//            qDebug("%d号枪VIN请求:%d\n",focus_gun_,chargingData->cmd7[focus_gun_-1].req_state);
            printf("网络状态: %d\n", chargingData->net_state);
    //        qDebug("当前是否为羊城通:SwipCardYCT1==%dSwipCardYCT2==%d\n",swipcard_YCT[0],swipcard_YCT[1]);
        }
        else
        {
            for(int i=0; i<GUN_AMOUNT; i++)
            {
                qDebug("枪%d内容变化:\n",i+1);
                qDebug("页面:%d\n",GUN_STATE[i].Page);
//                qDebug()<<"二维码:"<<GUN_STATE[i].m_QrCodeNum;
                qDebug("状态:\n错误代码:chargingData->gunmsg[%d].errcode[0] = %d\n",i,chargingData->gunmsg[i].errcode[0]);
                qDebug("电表异常代码chargingData->gunmsg[%d].meter_state = %d\n",i,chargingData->gunmsg[i].meter_state);
                qDebug("CAN通讯异常代码chargingData->can_state[%d] = %d\n",i,chargingData->can_state[i]);
                qDebug("启动状态chargingData->cmd2[%d].result = %d\n",i,chargingData->cmd2[i].result);
                qDebug("充电状态:chargingData->gunmsg[%d].charge_state = %d\n",i,chargingData->gunmsg[i].charge_state);
                qDebug("连接状态:chargingData->gunmsg[%d].gun_conn_state = %d\n",i,chargingData->gunmsg[i].gun_conn_state);
//                qDebug()<<"swipCardflag["<<i<<"] = "<<Refreash_Thread[i].swipCardflag;
//                qDebug()<<"appcharge["<<i<<"] = "<<Refreash_Thread[i].appcharge;
                qDebug("****************************************************************************************\n");
                msleep(800);
            }
        }
    sleep(1);
    }
}
